package com.video.result;
/*
@author baoshuai
@create 2022-05-14  8:21
*/

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "相应的VO对象", description = "封装接口返回给前端的数据")
public class ResultVO {
    //响应给前端的状态码
    @ApiModelProperty(value = "响应的状态码", dataType = "int")
    private Integer code;

    //响应给前端的提示信息
    @ApiModelProperty("响应的提示信息")
    private String message;

    //响应给前端的数据
    @ApiModelProperty("响应的数据")
    private Object data;

    public static ResultVO success() {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(AppHttpCodeEnum.SUCCESS.getCode());
        resultVO.setMessage(AppHttpCodeEnum.SUCCESS.getMsg());
        return resultVO;
    }

    public static ResultVO error() {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(AppHttpCodeEnum.ERROR.code);
        resultVO.setMessage(AppHttpCodeEnum.ERROR.getMsg());
        return resultVO;
    }

    public static ResultVO error(int code, String message) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMessage(message);
        return resultVO;
    }

    public static ResultVO success(Object data) {
        return new ResultVO(AppHttpCodeEnum.SUCCESS.getCode(), AppHttpCodeEnum.SUCCESS.getMsg(), data);
    }

    public static ResultVO success(AppHttpCodeEnum appHttpCodeEnum) {
        return new ResultVO(appHttpCodeEnum.getCode(), appHttpCodeEnum.getMsg(), null);
    }

    public static ResultVO success(AppHttpCodeEnum appHttpCodeEnum, Object data) {
        return new ResultVO(appHttpCodeEnum.getCode(), appHttpCodeEnum.getMsg(), data);
    }

    public static ResultVO success(int code, String message) {
        return new ResultVO(code, message, null);
    }
}
